<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8" />
	<title>单校手动对账</title>
	<link rel="stylesheet" href="../css/common2.css" />
	<link rel="stylesheet" href="/scriptZIP/vue-select.min.css">

	<style>
		.search_img {
			position: absolute;
			margin-top: 1px;
			right: 3%;
		}

		td>div {
			white-space: pre-wrap;
			padding-left: 5px;
		}

		.search_img {
			position: absolute;
			right: 3%;
		}

		.other {
			height: 33px;
			border: 1px solid #7a7a7a;
		}

		#startTime,
		#endTime {
			margin-top: -50px;
		}

		input {
			padding-left: 5px;
		}

		.hut_but_tz {
			display: inline-block;
			height: 38px;
			width: 108px;
			line-height: 38px;
			padding: 0 18px;
			background: url(../image/enter.png) no-repeat center center;
			color: #fff;
			white-space: nowrap;
			text-align: center;
			font-size: 14px;
			border: none;
			border-radius: 2px;
			cursor: pointer;
		}

		.orderXx_btn {
			padding: 2px 4px;
			background-color: #5dbeff;
			color: white;
			display: inline-block;
			border-radius: 4px;
		}

		.orderXx_btn:hover {
			cursor: pointer;
		}

		.orderXx_popup {
			position: fixed;
			left: 0px;
			top: 0px;
			width: 100%;
			height: 100%;
			z-index: 999999999;
			background-color: rgba(62, 62, 62, 0.5);
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.popup_box {
			color: black;
			width: 400px;
			height: 300px;
			background-color: white;
			border-radius: 12px;
		}

		.popup_box_title {
			height: 50px;
			line-height: 50px;
			font-size: 24px;
			position: relative;
			text-align: center;
			border-bottom: solid 1px #5c5c5c;
		}

		.popup_box_input {
			padding: 60px 0px 0px 37px;
			font-size: 16px;
			height: 120px;
		}

		.popup_box_input input {
			width: 232px;
			line-height: 27px;
			border-bottom: 1px solid #7a7a7a;
		}

		[v-if] {
			display: none;
		}

		.popup_box_btn_box {
			display: flex;
			justify-content: space-around;
		}

		.popup_box_btn {
			padding: 2px 0;
			width: 100px;
			text-align: center;
			color: white;
			border-radius: 4px;
			background-color: #5dbeff;
		}

		.popup_box_btn2 {
			color: #2c2c2c;
			background-color: #b9b9b9;
		}

		.popup_box_content {
			height: 190px;
		}

		.popup_box_check {
			display: flex;
			align-items: center;
			height: 190px;
			padding: 20px 20px 20px 30px;
			box-sizing: border-box;
			font-size: 16px;
		}
	</style>
</head>

<body>
	<div id="vue-root" style="margin-top: 50px">
		<div class="refresh" onclick="location.reload()">刷新</div>
		<input class="other" placeholder="请输入姓名" v-model="search.studentName" @keyup.enter="getData0"
			style="width: 145px; position: absolute; right: 420px" />
			<input class="other" placeholder="请输入订单号" v-model="search.tradeNo" @keyup.enter="getData0"
			style="width: 145px; position: absolute; right: 910px" />
		<select class="classes search" style="position: absolute; right: 260px" v-model="search.courseId">
			<option :value="undefined">请选择课程</option>
			<option v-for="course in coursess" :key="course.id" :value="course.id" v-text="course.name"></option>
		</select>
		<v-select class="search666" v-model="search.applicantId" :options="staffUsers" label="name" :reduce="staffUser => staffUser.id"
			placeholder="请选择申请人" :filterable="true" :clearable="true" style="position: absolute; right: 100px"
		  ></v-select>
		  <v-select class="search666" v-model="search.handleUser" :options="staffUsers" label="name" :reduce="staffUser => staffUser.id"
			placeholder="请选择经办人" :filterable="true" :clearable="true" style="position: absolute; right: 590px"
		  ></v-select>
		<!-- <select class="classes search" style="position: absolute; right: 100px" v-model="search.applicantId">
			<option :value="undefined">请选择申请人</option>
			<option v-for="staffUser in staffUsers" :key="staffUser.id" :value="staffUser.id" v-text="staffUser.name">
			</option>
		</select> -->
		<!-- <select class="classes search" style="position: absolute; right: 590px" v-model="search.handleUser">
			<option :value="undefined">请选择经办人</option>
			<option v-for="staffUser in staffUsers" :key="staffUser.name" :value="staffUser.name" v-text="staffUser.name">
			</option>
		</select> -->
		<select class="search" v-model="search.examine" style="position: absolute; right: 750px">
			<option :value="undefined">请选择状态</option>
			<option value="0">未提交</option>
			<option value="1">待审核</option>
			<option value="2">审核已通过</option>
			<option value="3">审核已驳回</option>
		</select>
		<!-- <input class="other" placeholder="请输入订单号" v-model="search.orderId" @keyup.enter="getData0"
			style="position: absolute; right: 100px" /> -->
		<input placeholder="开始时间" class="other" id="startTime" v-model="search.startTime"
			style="width: 65px; font-size: 12px; position: absolute; right: 170px" />
		<input placeholder="结束时间" class="other" id="endTime" v-model="search.endTime" style="
          width: 80px;
          font-size: 12px;
          position: absolute;
          right: 100px;
          border-left: none;
        " />
		<img src="../image/search.png" height="35" width="35" class="search_img" @click="getData0" />
		<div class="table">
			<table class="table_top">
				<thead>
					<tr>
						<th>
							<input type="checkbox" class="check-box" v-model="all" />序号
						</th>
						<th>课程</th>
						<th>校区</th>
						<th>学员姓名</th>
						<th>订单号</th>
						<th>金额</th>
						<th>申请人</th>
						<th>财务人员</th>
						<th>查看订单详情</th>
						<th>状态</th>
						<th>修改</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(order,index) in list" :key="order.id">
						<td>
							<input type="checkbox" class="check-box" v-model="order.checked" />{{index+1}}
						</td>
						<td v-text="formatCourseNames(order.courseNames)"></td>
						<td v-text="order.schoolName"></td>
						<td v-text="order.personName"></td>
						<td>
							<div class="orderXx_btn" v-if="!order.tradeNo||order.examine==3"
								@click="openOrderPopup(order)">填写订单号</div>
							<div v-else>{{order.tradeNo}}</div>
						</td>
						<td v-text="order.fee/100"></td>
						<td v-text="order.applicantName"></td>
						<td v-text="order.financeStaffName"></td>
						<td>
							<a :href="'/order_details.html?id='+order.id" class="btn"
								style="padding: 8px 16px; background-color: #69bbf4; color: white; text-decoration: none; border-radius: 4px;">查看</a>
						</td>
						<td>
							<span>{{['未提交','待审核','审核已通过','审核已驳回'][order.examine]}}</span>
							<span v-if="order.auditReason != null">
								<span style="text-decoration: underline; margin-left: 5px;"
									@click="showAuditReason(order)">
									查看原因
								</span>
							</span>
						</td>
						<td >
							<div class="option" style="position: relative;" v-if="able.edit">

								<div v-if="!order.tradeNo||order.examine==3" class="edit-icon option-icon"
									style="left: 40%; top:30%;position: absolute;">
									<a :href="'/beiyong.html?id='+order.id">
										<img class="img" src="../image/edit.png" height="20" width="20"
											onmouseover="this.src='../image/edit_light.png'"
											onmouseout="this.src='../image/edit.png'" />
									</a>
								</div>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<div class="delete" @click="batchDelete" v-if="able.del&&total>1">批量删除</div>
		<div class="delete" v-if="able.export" @click="exports">导出</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>
		<div style="float: right;">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>
		<div class="orderXx_popup" v-if="isshow" @click="isshow=false">
			<div class="popup_box" @click.stop>
				<div class="popup_box_title">填写订单号</div>
				<div class="popup_box_input">
					<span>订单号：</span>
					<input type="text" v-model="ordervalue" placeholder="请输入订单号" />
				</div>
				<div class="popup_box_btn_box">
					<div class="orderXx_btn popup_box_btn popup_box_btn2" @click="isshow=false">取消</div>
					<div class="orderXx_btn popup_box_btn" @click="submitOrder()">确定</div>
				</div>
			</div>
		</div>

		<div v-if="showReasonPopup" class="orderXx_popup" @click="closeReasonPopup">
			<div class="popup_box" @click.stop>
				<div class="popup_box_title">审核原因</div>
				<div class="popup_box_content" style="padding: 20px; font-size: 16px;">
					{{ selectedAuditReason || '无审核原因' }}
				</div>
				<div class="popup_box_btn_box">
					<div class="orderXx_btn popup_box_btn" @click="closeReasonPopup">关闭</div>
				</div>
			</div>
		</div>

	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/scriptZIP/vue-select.min.js"></script>
	<script src="/lib/laydate/laydate.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>
		Vue.component('v-select', VueSelect.VueSelect);
		var schoolId = top_params().id;
		var agentId = localStorage.getItem('agentId');
		var app = new Vue(
			merge({
				data: {
					isshow: false,
					isshowCheck: false,
					urls: {
						del: "/pc/order/del",
						list: "/pc/order/manualList?schoolId=" + schoolId,
					},
					coursess: [],
					charges: [],
					staffUsers: [],
					oneOrder: '',//一条订单
					ordervalue: '',//订单号
					checkType: 2,
					showReasonPopup: false,
					selectedAuditReason: '', // 保存当前的审核原因
				},
				created: function () {
					abled('shouDongDuiZhang', this);
					this.getData();
					axios.get('/pc/staffUser/all/' + agentId).then(function (res) {
						this.staffUsers = res.data;
					}.bind(this));
					axios.get("/pc/course/all/" + agentId).then(
						function (res) {
							this.coursess = res.data;
						}.bind(this)
					);
					axios.get("/pc/charge/all/" + schoolId).then(
						function (res) {
							this.charges = res.data;
						}.bind(this)
					);
				},
				methods: {
					showAuditReason(order) {
						this.selectedAuditReason = order.auditReason || '无审核原因';
						this.showReasonPopup = true;
					},
					closeReasonPopup() {
						this.showReasonPopup = false;
						this.selectedAuditReason = '';
					},
					formatCourseNames(names) {
						return names.join(', ');
					},
					exports: function () {
						var q = Qs.stringify(this.search);
						if (q) q = "?" + q;
						location.href = "/pc/order/export/" + schoolId + q;
					},

					openOrderPopup(item) {
						this.isshow = true
						this.oneOrder = item
					},
					submitOrder() {
						if (!this.ordervalue) return alert('订单号不能为空');
						var obj = new FormData()
						obj.append('tradeNo', this.ordervalue)
						obj.append('applicantId', localStorage.getItem('staffUserId'))
						axios
							.post("/pc/order/updateType/" + this.oneOrder.id, obj)
							.then(({ data }) => {
								this.getData();
								alert('已提交');
								this.isshow = false
								this.oneOrder = ''
							})
							.catch((error) => {

								alert(error.msg);
							});
					},
					openCheckPopup(item) {
						this.oneOrder = item
						if (item.examine == 2) {
							this.checkType = item.examine
						} else if (item.examine == 3) {
							this.checkType = item.examine
						}
						this.isshowCheck = true
						console.log(this.oneOrder);
					},
					submitCheck() {
						var obj = new FormData()
						obj.append('type', this.checkType)
						obj.append('financeStaffId', localStorage.getItem('staffUserId'))
						axios
							.post("/pc/order/updateType1/" + this.oneOrder.id, obj)
							.then(({ data }) => {
								this.getData();
								alert('审核完成');
								this.isshowCheck = false
								this.oneOrder = ''
							})
							.catch((error) => {

								alert(error.msg);
							});
					}
				},
			})
		);

		["startTime", "endTime"].forEach(function (it) {
			laydate.render({
				elem: "#" + it,
				type: "datetime",
				done: function (value, date, endDate) {
					app.search[it] = value;
				},
			});
		});
	</script>
</body>

</html>